<!DOCTYPE HTML>

<html>
<center>
        <head>
        
                <title>
                
                        Space Shot
                
                </title>
           
	<script src="Classe/Shoot.js"></script>
	<script src="Classe/Player.js"></script> 
	<script src="Classe/sceneintro.js"></script> 
	<script src="Classe/scenelevel1.js"></script>
	<script src="Classe/backgound.js"></script>	 
	<script src="Classe/inimigo.js"></script>
        
       </head>
        
        <body>
        
          <br/>
                
                <canvas width="768" height="1024" id="main" style="border:1px solid #000000;"></canvas>
                
	<script>                
              
              
window.addEventListener("keydown", key_down, true);
window.addEventListener("keyup", key_up, true);
              
              
              
	var canvas = document.getElementById("main");
	var screen = canvas.getContext("2d");
	
	var SCENES = { INTRO: 0 , LEVEL1: 1 }
	
	var currentScene = SCENES.INTRO;
	
	var tela_inicial = new Sceneintro();
	
	var level_01 = new Scenelevel1();
	
	var tela_h = 1024;
	
	var tela_w = 768;
	
	var pause = false;

Load();	
	
	
function Load()
{

	
	
Loop();


}



              
function Update()
{
	if (pause)
	{
		return;
	}
	
	switch(currentScene)
	{
	case SCENES.INTRO:
	
	

break;

	case SCENES.LEVEL1:

	//tela_inicial.update();
	
	level_01.update();
	
	
	


break;

}//FIM DO SWITCH

}//FIM DO UPDATE              
              




function Draw()
{
	
	screen.clearRect(0,0,768,1024)
	switch(currentScene)
{
	case SCENES.INTRO:
	
	tela_inicial.draw();

	break;
	
	case SCENES.LEVEL1:
	
	level_01.draw();
	

	if (pause == true)
	{
	screen.font = "100px Comic San MS";
	screen.fillStyle = "#FFFFFF";
	screen.fillText("Pause",240,512);
	}

 break;
}//fim do switch

}// fim do draw              
              
function Loop()
{
	Update();
	
	Draw();
	
setTimeout (Loop, 30 );
	
	
}              
             


function key_down(key) 
{ 
	if(key.keyCode == "80") // P
	{
		pause = !pause;
	}		
	
	switch(currentScene)
	
	{
		case SCENES.INTRO:
		{
			tela_inicial.key_down(key);
		}
	break;
	
		case SCENES.LEVEL1:
		{
			level_01.key_down(key);
		}
		
	break;
	}
	
			
}

function key_up(key) 
{
		
	switch(currentScene)
	{
		case SCENES.INTRO:
		{
		
		}
	break;
	
		case SCENES.LEVEL1:
		{
			level_01.key_up(key);
		}
	break;
	}
}             
	</script>
                
        </body>
</center>        
</html>